<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Repairs and compacts this database</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mongodb.preverror.html">MongoDB::prevError</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mongodb.reseterror.html">MongoDB::resetError</a></div>
 <div class="up"><a href="class.mongodb.html">MongoDB</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="mongodb.repair" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoDB::repair</h1>
  <p class="verinfo">(PECL mongo &gt;=0.9.0)</p><p class="refpurpose"><span class="refname">MongoDB::repair</span> &mdash; <span class="dc-title">Repairs and compacts this database</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongodb.repair-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">array</span> <span class="methodname"><strong>MongoDB::repair</strong></span>
    ([ <span class="methodparam"><span class="type">bool</span> <code class="parameter">$preserve_cloned_files</code><span class="initializer"> = <strong><code>FALSE</code></strong></span></span>
   [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$backup_original_files</code><span class="initializer"> = <strong><code>FALSE</code></strong></span></span>
  ]] )</div>

  <p class="para rdfs-comment">
   This creates a fresh copy of all database data.  It will remove any corrupt 
   data and compact and large stretches of free space it finds.  This is a very
   slow operation on a large database.
  </p>
  <p class="para">
   This is usually run from the shell or the command line, not the driver.
  </p>
  <p class="para">  
   It is equivalent to the function:
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">public&nbsp;function&nbsp;</span><span style="color: #0000BB">repair</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">command</span><span style="color: #007700">(array(</span><span style="color: #DD0000">'repairDatabase'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">));<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-mongodb.repair-parameters">
  <h3 class="title">参数</h3>    
  <p class="para">
   <dl>

    
     <dt>

      <em><code class="parameter">preserve_cloned_files</code></em>
     </dt>

     <dd>

      <p class="para">
       If cloned files should be kept if the repair fails.
      </p>
     </dd>

       
    
     <dt>

      <em><code class="parameter">backup_original_files</code></em>
     </dt>

     <dd>

      <p class="para">
       If original files should be backed up.
      </p>
     </dd>

       
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mongodb.repair-returnvalues">
  <h3 class="title">返回值</h3>  
  <p class="para">
   Returns db response.
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-mongodb.repair-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   MongoDB core docs on <a href="http://docs.mongodb.org/manual/reference/command/repairDatabase/" class="link external">&raquo;&nbsp;repairDatabase</a>.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-mongodb.repair-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-1399">
   <p><strong>Example #1 <span class="function"><strong>MongoDB::repair()</strong></span> example</strong></p>
   <div class="example-contents"><p>This example demonstrates how to repare and compact a database.</p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$db&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$mongo</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">foo</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$response&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">repair</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$response</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程的输出类似于：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
Array
(
    [ok] =&gt; 1
)
</pre></div>
   </div>
  </div>  
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mongodb.preverror.html">MongoDB::prevError</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mongodb.reseterror.html">MongoDB::resetError</a></div>
 <div class="up"><a href="class.mongodb.html">MongoDB</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
